/**
 * 
 */
package com.xb.cloud.product.merchant.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.xb.cloud.product.merchant.service.client.ProductMongoService;
import com.xb.cloud.product.merchant.service.client.bo.ProductMongoBo;
import com.xb.cloud.product.merchant.service.client.bo.ProductShopSeriesMongoBo;
import com.xb.cloud.product.service.business.dao.ProductMongoDao;
import com.xb.cloud.service.client.ServiceReturnCodes;
import com.xb.cloud.service.client.ServiceReturnInfo;
import com.xb.cloud.service.client.ServiceReturnUtils;

/**
 * Productmongo 数据结构操作接口
 * 
 * @author kexue
 *
 */
@Service
public class ProductMongoServiceImpl implements ProductMongoService {

	@Resource
	private ProductMongoDao productMongoDao;

	/**
	 * 保存
	 */
	@Override
	public ServiceReturnInfo  save(ProductMongoBo pmongo) {
		boolean save = productMongoDao.save(pmongo);
		if(save){
			return ServiceReturnUtils.success(save);
		}else{
			return ServiceReturnUtils.error(ServiceReturnCodes.PRODUCT_MONGO_SAVE_FAILED);
		}
	}

	/**
	 * 根据id查找
	 */
	@Override
	public ServiceReturnInfo findById(Long id) {
		
		ProductMongoBo productMongoBo = productMongoDao.findById(id);
		return ServiceReturnUtils.success(productMongoBo);
		 
	}

	
	/**
	 * 保存系列品 ： 产品店铺系列组合Bo
	 * 
	 * @param pmongo
	 * @return
	 */
	public ServiceReturnInfo saveProductShopSeriesMongoBo(ProductShopSeriesMongoBo productShopSeriesMongoBo) {
		
		boolean save = productMongoDao.saveProductShopSeriesMongoBo(productShopSeriesMongoBo);
		if(save){
			return ServiceReturnUtils.success(save);
		}else{
			return ServiceReturnUtils.error(ServiceReturnCodes.PRODUCT_SERIES_MONGO_SAVE_FAILED);
		}
		 
	}

	/**
	 * 根据ProductId + ShopId 查询 产品店铺系列组合Bo
	 * @param id
	 * @return
	 */
	public ServiceReturnInfo findByProductShopId(String id) {
		ProductShopSeriesMongoBo  productShopSeriesMongoBo  = productMongoDao.findProductShopSeriesMongoBoById(id);
		return ServiceReturnUtils.success(productShopSeriesMongoBo);
	}
}
